package com.itheima.clientAndService01;

import java.util.HashSet;

public class MainClass01 {
    public static void main(String[] args) {
        HashSet<Student> students = new HashSet<>();

        Student student1 = new Student("张三",23);
        Student student2 = new Student("张三",23);
        Student student3 = new Student("李四",24);

        students.add(student1);
        students.add(student2);
        students.add(student3);

        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());
        System.out.println(student3.hashCode());

        System.out.println("--------------------");

        //数值型的哈希值是自己
        Integer integer = 1000;
        System.out.println(integer.hashCode());//1000

        //hashcode相同不一定两个字符串的值相同
        //两个字符串相同，哈希值肯定相同
        System.out.println("重地".hashCode());//1179395
        System.out.println("通话".hashCode());//1179395

        System.out.println("--------------------");

        for (Student student : students) {
            System.out.println(student);
        }
    }
}
